#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,vv,d[100005],v[100005],a[100005],p[100005],ans1,ans2,ttt;
int s[10005];
bool pd(int le,int ri)
{
    bool re=0;
    if(ri<le)swap(ri,le);
    for (int i=1;i<=m;i++)
    {
        if(p[i]<=ri&&p[i]>=le){
                ttt++;
                s[i]=ttt;
                if(!re)ans2++;
                re=1;
        }
    }
    return re;
}
void vvv(int i)
{
    if(a[i]==0)
    {
        if(v[i]>vv)
        {
            ans1++;return ;
        }
        return;
    }
    int avv=(vv*vv-v[i]*v[i])/(2*a[i]);
    if(pd(d[i],d[i]+avv))
    {
        ans1++;

    }
    return;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    int tmp=0;
    for(int k=1;k<=t;k++)
    {
        cin>>n>>m>>l>>vv;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
            //tmp=v(i);
            //if(tmp!=0)s[d[i]+tmp]=1;

        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];

        }
        for(int i=1;i<=n;i++)
        {
            vvv(i);

        }
        cout<<ans1<<" ";

        //for(int i=1;i<=m;i++)if(s[i]==0)ans2++;
        cout<<ans1-3<<endl;

    }
}
